<template>
	<view class="content">
		<view class="sharepage-wrap">
			<view class="sharepage-content">
				<view class="myinvitationcode">我的邀请码</view>
				<view class="subtitle">好友在APP中注册时输入</view>
				<view class="code">{{myinvitationcode}}</view>
				<view class="copy" @click="copynow">复制邀请码</view>
				<view class="line"></view>
				<view>我的二维码</view>
				<view>扫描二维码并在链接页面中完成注册</view>
				<view class="">
					<image class="qrcode" :src="qrcode" mode=""></image>
				</view>
				
				<!-- 
				 #ifdef APP-PLUS
				 
				 <view class="sharebtn">
				 	<button type="default" @click="share1">立即邀请</button>
				 </view>
				 #endif
				 
				 #ifdef H5 || MP-WEIXIN
				 			
				 <view class="sharebtn">
				 	<button type="default" open-type="share" >立即邀请</button>
				 </view>
				 #endif
				 -->
			</view>
		</view>
	</view>


</template>

<script>
	export default {
		data() {
			return {
				myinvitationcode: '',
				qrcode:'',
			}
		},
		onLoad() {
			console.log(111)
			this.getmycode()
		},
		methods: {
			onShareAppMessage() {
				let that = this;
				console.log(this.myinvitationcode)
				return {
					title: '这是分享出去的小程序',
					path: 'subPackage/forgetPwd/forgetPwd?type=regist' + '&myinvitationcode='+this.myinvitationcode
				};
			},
			share1() {
				uni.share({
					provider: "weixin",
					scene: "WXSceneSession",
					type: 0,
					href: "http://gua.qinmaoyi.cn/mregister?inviteCode="+this.myinvitationcode,
					title: "朋友邀请你来注册拉~",
					summary: "",
					imageUrl: "",
					success: function(res) {
						console.log("success:" + JSON.stringify(res));
					},
					fail: function(err) {
						console.log("fail:" + JSON.stringify(err));
					}
				});
			},
			getmycode(){
				
				let that = this;
				that.$Request.request('/api/user_center/shareDetail', 'GET', {}).then(res => {
					if (res.status == 1) {
						that.myinvitationcode =res.data.inviteCode;
						that.qrcode =res.data.inviteQrcode
					}
					
				}).catch(err => {
					console.log(err)
				})
			},
			copynow() {
				uni.setClipboardData({
					data: this.myinvitationcode,
					success: () => {
						this.$api.msg('分享链接已复制到剪切板！')
					}
				})
			},

		}
	}
</script>

<style lang="scss" scoped>
	.sharepage-wrap {
		font-size: 14px;

		.sharepage-content {
			text-align: center;
			padding: 20px;
			line-height: 2.2;

			.code {
				color: rgb(240, 0, 87);
				font-size: 24px;
				opacity: 0.9;
				font-weight: 600;
			}

			.copy {
				width: 90px;
				margin: 0 auto;
				border: 1px solid rgb(240, 0, 87);
				color: rgb(240, 0, 87);
				border-radius: 5px;
				margin-bottom: 20px;
			}

			.line {
				width: 100%;
				height: 1px;
				background-color: rgb(240, 0, 87);
				margin-bottom: 10px;
				opacity: 0.3;
			}

			.qrcode {
				width: 100px;
				height: 100px;
				margin: 0 auto;
				margin-bottom: 15px;

				img {
					width: 100%;
					height: 100%;
				}
			}

			.sharebtn {
				button {
					background-color: rgb(240, 0, 87) !important;
					color: #fff !important;
				}
			}

			.myinvitationcode {
				.subtitle {}


			}
		}
	}
</style>
